package com.wanshi.servlet;

import com.wanshi.entity.User;
import com.wanshi.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//1111111111111111111
//33333333333332
@WebServlet("/ss/detailUser")
public class DeailServlet extends HttpServlet {

    private UserService userService = new UserService();

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //1 获取id
        String id = request.getParameter("id");


        //2 根据id查询
        User user = userService.findById(id);


        //3 存入request域,转发
        request.setAttribute("user",user);
        request.getRequestDispatcher("/detail.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}

